﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp1
{
    class DBHelper
    {
        private static readonly string connstr = "server=.;database=Blogs;user=sa;pwd=123456";

        public static DataTable Select(string sql)
        {
            SqlConnection myconn = new SqlConnection(connstr);
            myconn.Open();

            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, myconn);

            DataTable dt = new DataTable();

            dataAdapter.Fill(dt);

            return dt;

        }


        public static int Heeal(string sql)
        {
            SqlConnection myconn = new SqlConnection(connstr);

            myconn.Open();

            SqlCommand sqlCommand = new SqlCommand(sql, myconn);


            return sqlCommand.ExecuteNonQuery();
        }
    }
}
